package com.heima.admin.job;

import com.heima.admin.feign.WemediaFeign;
import com.heima.admin.service.WemediaNewsAutoScanService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Log4j2
public class WeMediaNewsAutoScanJob {

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @Autowired
    private WemediaFeign wemediaFeign;

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> wemediaAutoScanJob(String param) throws Exception {
        log.info("自媒体文章审核调度任务开始执行....");
        System.out.println("自媒体文章审核调度任务开始执行");
        List<Integer> release = wemediaFeign.findRelease();// 查询所有状态魏8 且过了发布时间的自媒体文章的id
        System.out.println(release);
        if(release != null && release.size()>0){
            for (Integer id : release) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);//自媒体文章审核
            }
        }

        log.info("自媒体文章审核调度任务执行结束....");
        return ReturnT.SUCCESS;
    }
}
